package com.lv.suyiyong.hfr.adapter

import android.view.View
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

import com.lv.common.imp.OnPositionTListener
import com.lv.service.bean.CommonNameBean
import com.lv.suyiyong.hfr.R

/**
 * 作者： ygx
 * 创建日期：2022/6/24 8:10 PM
 * 签名： 天行健，君子以自强不息；地势坤，君子以厚德载物。
 *      _              _           _     _   ____  _             _ _
 *     / \   _ __   __| |_ __ ___ (_) __| | / ___|| |_ _   _  __| (_) ___
 *    / _ \ | '_ \ / _` | '__/ _ \| |/ _` | \___ \| __| | | |/ _` | |/ _ \
 *   / ___ \| | | | (_| | | | (_) | | (_| |  ___) | |_| |_| | (_| | | (_) |
 *  /_/   \_\_| |_|\__,_|_|  \___/|_|\__,_| |____/ \__|\__,_|\__,_|_|\___/
 *
 * You never know what you can do until you try !
 * ----------------------------------------------------------------
 *
 */
class GoodsParmasAdapter(private val datas: MutableList<CommonNameBean>?) :
    BaseQuickAdapter<CommonNameBean, BaseViewHolder>
        (R.layout.item_parmas_goods, datas) {

    override fun convert(helper: BaseViewHolder, item: CommonNameBean) {

        val clParent: ConstraintLayout = helper.getView<ConstraintLayout>(R.id.cl_parent)
        val mTvBrandBottom = helper.getView<TextView>(R.id.tv_brand_bottom)
        val mTvBrand = helper.getView<TextView>(R.id.tv_brand)
        val viewLine = helper.getView<View>(R.id.view_line)
        mTvBrand.text = item.value
        mTvBrandBottom.text = item.name
        val layoutPosition = helper.layoutPosition
        val size = datas?.size ?: 1
        viewLine.visibility = if (size - 1 == layoutPosition) View.GONE else View.VISIBLE
        clParent.setOnClickListener { mOnViewItemClickListener?.onClick(layoutPosition, item) }
    }

    var mOnViewItemClickListener: OnPositionTListener<CommonNameBean>? = null


}